#!/bin/bash -e

function info() {
echo Usage: `basename $0` 'list'
exit 1
}

while getopts  ":p:f:" opt; do
	case  $opt  in
		p) out_prefix=$OPTARG;;
		f) suffix=$OPTARG;;
		*) info;;
	esac
done
shift $(($OPTIND - 1))


if [ $# -lt 1 ]; then info; fi

. $var

# awk '$2~/^[01]/' $1 > $1.clear

# rf_pre_merge_site.sh -p$out_prefix $1.clear 10000

# rf_methy.sh -p$out_prefix $out_prefix.test.merge.100.3.txt $out_prefix.b450k.site_merge.random_site.txt
list=$1
bed=/mnt/ilustre/app/medical/data/adm/1.bed
interval=1.realn.intervals

# IFS=$'\n'
for i in `cat $list`; do
    
    # nam=`basename $i|cut -f1 -d_`
    
    # r1=`echo $i|cut -f1 -d' '`
    # r2=`echo $i|cut -f2 -d' '`
    # echo $nam
    # echo $i 
    # cutadp.sh $r1 $r2
    # aln0818.sh -s$nam -p$out_prefix.$nam -b$bed $out_prefix.1.cut.fastq $out_prefix.2.cut.fastq
    
    base=`basename $i .bam`
    # realign_bt.sh -i $bed -r$interval -p$base $i
    deldup.sh -m -p$base $i
    recal0630.sh -l $bed -p$base $base.markdup.bam
    hap.sh -p$base $base.realn.recal.bam $bed
       
done

# realign_bt.sh -i ../bed 1.merge.bam

. $cmd_done